//
//  WebViewController.m
//  XiangMu_ManHua
//
//  Created by dllo on 15/10/27.
//  Copyright © 2015年 蓝鸥科技. All rights reserved.
//

#import "WebViewController.h"

@interface WebViewController ()<UIWebViewDelegate,MBProgressHUDDelegate>{
    MBProgressHUD *HUD;
}

@property (nonatomic ,strong) UIWebView *web;
@property (nonatomic, strong) UIButton *backB;

@end

@implementation WebViewController

- (void)viewWillAppear:(BOOL)animated
{
    self.tabBarController.tabBar.hidden = YES;
}

- (void)viewWillDisappear:(BOOL)animated
{
    self.tabBarController.tabBar.hidden = NO;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    
    
    self.web.scalesPageToFit = NO;
    self.web = [[UIWebView alloc] initWithFrame:CGRectMake(0, -49, self.view.bounds.size.width , self.view.bounds.size.height + 49 )];
    
    self.web.delegate = self;
    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:_str1]];
    [self.view addSubview:_web];
    [_web loadRequest:request];
    
    for (id subview in _web.subviews)
        if ([[subview class] isSubclassOfClass: [UIScrollView class]])
            ((UIScrollView *)subview).bounces = NO;
    
    HUD = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    HUD.labelText =  @"数据加载中...";
    
    // 返回按钮
    self.backB = [UIButton buttonWithType:UIButtonTypeSystem];
    _backB.backgroundColor = [UIColor colorWithRed:1.000 green:0.000 blue:0.139 alpha:1.000];
    _backB.frame = CGRectMake(20, 20, 40, 40);
    _backB.layer.cornerRadius = 20;
    UIImage *backI = [[UIImage imageNamed:@"picture1"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    [_backB setImage:backI forState:UIControlStateNormal];
    [_backB setImageEdgeInsets:UIEdgeInsetsMake(5, 5, 5, 5)];
    [_backB addTarget:self action:@selector(backAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:_backB];
}

- (void)backAction:(UIButton *)btn
{
    [self dismissViewControllerAnimated:YES completion:^{
        
    }];
}

- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    [HUD hide:YES afterDelay:0];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
